#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QIcon icon(":/image/1.png");
    ui->pushButton_target->setIcon(icon);
    ui->pushButton_target->setIconSize(QSize(208, 208));
    ui->pushButton_down->setIcon(QIcon(":/image/down.png"));
    ui->pushButton_up->setIcon(QIcon(":/image/up.png"));
    ui->pushButton_left->setIcon(QIcon(":/image/left.png"));
    ui->pushButton_right->setIcon(QIcon(":/image/right.png"));
    ui->pushButton_down->setIconSize(QSize(37, 37));
    ui->pushButton_up->setIconSize(QSize(50, 50));
    ui->pushButton_left->setIconSize(QSize(50, 50));
    ui->pushButton_right->setIconSize(QSize(50, 50));
    // ui->pushButton_up->setShortcut(QKeySequence("w"));
    // ui->pushButton_left->setShortcut(QKeySequence("a"));
    // ui->pushButton_down->setShortcut(QKeySequence("s"));
    // ui->pushButton_right->setShortcut(QKeySequence("d"));

    // ui->pushButton_up->setShortcut(QKeySequence(Qt::Key_W + Qt::CTRL));
    ui->pushButton_up->setShortcut(QKeySequence(Qt::Key_W));
    ui->pushButton_left->setShortcut(QKeySequence(Qt::Key_A));
    ui->pushButton_down->setShortcut(QKeySequence(Qt::Key_S));
    ui->pushButton_right->setShortcut(QKeySequence(Qt::Key_D));
    QPushButton* tmp = new QPushButton("&d", this);
    ui->pushButton_right->setAutoRepeat(true);
    ui->pushButton_up->setAutoRepeat(true);
    ui->pushButton_down->setAutoRepeat(true);
    ui->pushButton_left->setAutoRepeat(true);

    ui->radioButton_female->setChecked(true);
    ui->label->setText("你选择的性别是：女");
    // ui->radioButton_unknow->setCheckable(false);
    ui->radioButton_unknow->setEnabled(false);
}

void Widget::on_radioButton_male_clicked()
{
    ui->label->setText("你选择的性别是：男");
}


void Widget::on_radioButton_female_clicked()
{
    ui->label->setText("你选择的性别是：女");
}


void Widget::on_radioButton_unknow_clicked()
{
    ui->label->setText("你选择的性别是：未知");
}

Widget::~Widget()
{
    delete ui;
}
static const int img_step = 10;
void Widget::on_pushButton_up_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x(), rect.y() - img_step, rect.width(), rect.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x(), rect.y() + img_step, rect.width(), rect.height());
}

void Widget::on_pushButton_left_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x() - img_step, rect.y(), rect.width(), rect.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x() + img_step, rect.y(), rect.width(), rect.height());
}

void Widget::on_radioButton_clicked(bool checked)
{
    qDebug() << "checked: " << checked;
}


void Widget::on_radioButton_2_pressed()
{
    qDebug() << "pressed";
}

void Widget::on_radioButton_3_released()
{
    qDebug() << "released";
}

void Widget::on_radioButton_4_toggled(bool checked)
{
    qDebug() << "toggled: " << checked;
}

